{% extends "report/common/search_run.html" %}
{% block report %}
{% if report_data %}
	{% if queries %}
	<div class="queries">
		<ul>
		{% for k, v in queries.items %}
			<li><label>{{ k|title }}:</label>{{ v|safe }};</li>
		{% endfor %}
			<li class="clear"></li>
		</ul>
	</div>
	{% endif %}

	<div class="reportSummary01">
		<ul>
			<li>
				Plan:<span>{{ report_data.plans_count }}</span>
				Run:<span>{{ report_data.runs_count }}</span>
				Case-Run:<span>{{ report_data.case_runs_count }}</span>
			</li>
		</ul>
		<div class="clear"></div>
	</div>

	{% for plan, builds_count, runs_count, caseruns_count, status_matrix in report_data.reports %}
	<div class="reportSummary01">
		<ul><li class="tagTab">Plan: <a href="{% url 'test_plan_url_short' plan.pk %}">{{ plan }}</a></li></ul>
		<ul>
			<li>Builds:<span>{{ builds_count }}</span></li>
			<li>Runs:<span>{{ runs_count }}</span></li>
			<li>Case Runs:<span>{{ caseruns_count }}</span></li>
		</ul>
		<div class="clear"></div>
	</div>

	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="listTdReport">
		<thead>
			<tr>
				<th class="w200">Build</th>
				<th>Run</th>
				<th class="w50">Idle</th>
				<th class="w50">Running</th>
				<th class="w50">Paused</th>
				<th class="w50">Passed</th>
				<th class="w50">Failed</th>
				<th class="w50">Blocked</th>
				<th class="w50">Error</th>
				<th class="w50">Waived</th>
			</tr>
		</thead>
		<tbody>
			{% for build, run, status_subtotal in status_matrix %}
			<tr>
				{% ifnotequal build.1 None %}
				<td rowspan="{{ build.1 }}" class="bgRowspan"><span>{{ build.0 }}</span></td>
				{% endifnotequal %}
				<td><a href="{% url 'testruns-get' run.pk %}">{{ run.summary }}</a></td>
				<td><a href="{{ report_url }}{{path_without_build}}&r_build={{build.0.pk}}&run={{ run.pk }}&status=idle">{{ status_subtotal.IDLE|default:0 }}</a></td>
				<td><a href="{{ report_url }}{{path_without_build}}&r_build={{build.0.pk}}&run={{ run.pk }}&status=running">{{ status_subtotal.RUNNING|default:0 }}</a></td>
				<td><a href="{{ report_url }}{{path_without_build}}&r_build={{build.0.pk}}&run={{ run.pk }}&status=paused">{{ status_subtotal.PAUSED|default:0 }}</a></td>
				<td><a href="{{ report_url }}{{path_without_build}}&r_build={{build.0.pk}}&run={{ run.pk }}&status=passed">{{ status_subtotal.PASSED|default:0 }}</a></td>
				<td><a href="{{ report_url }}{{path_without_build}}&r_build={{build.0.pk}}&run={{ run.pk }}&status=failed">{{ status_subtotal.FAILED|default:0 }}</a></td>
				<td><a href="{{ report_url }}{{path_without_build}}&r_build={{build.0.pk}}&run={{ run.pk }}&status=blocked">{{ status_subtotal.BLOCKED|default:0 }}</a></td>
				<td><a href="{{ report_url }}{{path_without_build}}&r_build={{build.0.pk}}&run={{ run.pk }}&status=error">{{ status_subtotal.ERROR|default:0 }}</a></td>
				<td><a href="{{ report_url }}{{path_without_build}}&r_build={{build.0.pk}}&run={{ run.pk }}&status=waived">{{ status_subtotal.WAIVED|default:0 }}</a></td>
			</tr>
			{% endfor %}
		</tbody>
	</table>
	{% empty %}
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="listTdReport">
		<thead>
			<tr>
				<th class="w200">Build</th>
				<th>Run</th>
				<th class="w50">Idle</th>
				<th class="w50">Running</th>
				<th class="w50">Paused</th>
				<th class="w50">Passed</th>
				<th class="w50">Failed</th>
				<th class="w50">Blocked</th>
				<th class="w50">Error</th>
				<th class="w50">Waived</th>
			</tr>
		</thead>
		<tbody>
			<tr><td colspan="10" align="center">No report data.</td></tr>
		</tbody>
	</table>
	{% endfor %}
{% endif %}
{% endblock %}
